#include "ChatUI.h"
#include "ui_ChatUI.h"
#include "ChatMessageUI.h"
#include "Message/TextChatMessage.h"

#include <QDebug>

ChatUI::ChatUI(QWidget *parent) :
    QListWidget(parent)
{
   // InitUI();
}

void ChatUI::InitUI(void){
   // connect(ui->psbSend, SIGNAL(clicked(bool)), this, SLOT(SendMessage(bool)));
}

ChatUI::~ChatUI()
{

}

void ChatUI::SendMessage(CChatMessage* pChatMessage){
//    QString strMessage = ui->textEdit->toPlainText();
   // ui->textEdit->setText("");
  //  pChatMessage->SetContext(strMessage);
    QWidget* pWidget = new ChatMessageUI(pChatMessage);
    QListWidgetItem* item = new QListWidgetItem(this);

    QSize size = pChatMessage->GetSize();
  //  qDebug()<<size;
    item->setSizeHint(QSize(180, size.height()));
    setItemWidget(item, pWidget);

    qDebug() << "send";
}

void ChatUI::SendMessage(bool){
    CChatMessage* pChatMessage = new CTextChatMessage();
//    QString strMessage = ui->textEdit->toPlainText();
   // ui->textEdit->setText("");
    pChatMessage->SetContext("");
    QWidget* pWidget = new ChatMessageUI(pChatMessage);
    QListWidgetItem* item = new QListWidgetItem(this);

    QSize size = pChatMessage->GetSize();
  //  qDebug()<<size;
   // item->setSizeHint(QSize(180, 30));
    setItemWidget(item, pWidget);

    qDebug() << "send";
}
